package reflect;

import reflect.annotations.AutoRunClass;

import java.io.File;
import java.net.URISyntaxException;

public class Test3 {
    public static void main(String[] args) throws Exception {
        File dir = new File(
                Test3.class.getResource(".").toURI()
        );
        File[] subs = dir.listFiles(f->f.getName().endsWith(".class"));
        for(File sub : subs) {
            String fileName = sub.getName();
            String className = fileName.substring(0, fileName.indexOf("."));
            Class cls = Class.forName(
                    Test3.class.getPackage().getName() + "." + className);
            if(cls.isAnnotationPresent(AutoRunClass.class)){
                System.out.println(className+":被@AutoRunClass标注了!");
            }else{
                System.out.println(className+":没有被@AutoRunClass标注了!");
            }

        }
    }
}
